package inventory.master.view;

import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;
import javax.swing.JComboBox;

public class MaterialManagementView extends JPanel
{
	private JButton btnSave;
	private JButton btnUpdate;
	private JButton btnBack;
	private JButton btnSearch;
	private JButton btnForward;
	private JButton btnClear;
	private JLabel lblMaterialName;
	private JLabel lblCategory;
	private JLabel lblSpecification;
	private JLabel lblUnit;
	private JTextField tMaterialName;
	private JComboBox categorycombo;
	private JComboBox tSpecification;
	private JTextField tUnit;
	private JButton[] buttongrp=new JButton[8];
	private JLabel lblMcode;
	private JTextField tMcode;
	private JTextField tNewSpecification;
	private JButton btnStatus;
	private JLabel lblActive;
	
	public MaterialManagementView() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		this.setBackground(Color.GRAY);
	    this.setPreferredSize(new Dimension(360, 584));
		
		/*
		 * SETTING LABELS
		 */
		 String[] labelsTitle = {"Name: ", "Phone: ", "Email: ", "Address: "};
		 JLabel[] labels=new JLabel[4];
		 
		 for(int i=0;i<labels.length;i++)
		 {
			 labels[i]=new JLabel(labelsTitle[i], JLabel.TRAILING);
			 add(labels[i]);
		 }
		
		tMcode = new JTextField();
		tMcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tMcode, 10, SpringLayout.NORTH, this);
		add(tMcode);
		tMcode.setColumns(10);
			
		lblMcode = new JLabel("Material Code :");
		lblMcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, lblMcode, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.EAST, lblMcode, -10, SpringLayout.WEST,tMcode);
		add(lblMcode);
		 
		lblMaterialName = new JLabel("Material Name");
		lblMaterialName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblMaterialName, 20, SpringLayout.SOUTH,tMcode);
		springLayout.putConstraint(SpringLayout.WEST, lblMaterialName, 30, SpringLayout.WEST, this);
		add(lblMaterialName);
		
		tMaterialName = new JTextField();
		tMaterialName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tMaterialName, 6, SpringLayout.SOUTH, lblMaterialName);
		springLayout.putConstraint(SpringLayout.EAST, tMcode, 0, SpringLayout.EAST,tMaterialName);
		springLayout.putConstraint(SpringLayout.WEST, tMaterialName, 30, SpringLayout.WEST,this);
		add(tMaterialName);
		tMaterialName.setPreferredSize(new Dimension(300, 23));
		
		lblCategory = new JLabel("Category");
		lblCategory.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCategory, 20, SpringLayout.SOUTH, tMaterialName);
		springLayout.putConstraint(SpringLayout.WEST, lblCategory, 0, SpringLayout.WEST, lblMaterialName);
		add(lblCategory);
		
		categorycombo = new JComboBox();
		categorycombo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, categorycombo, 6, SpringLayout.SOUTH, lblCategory);
		springLayout.putConstraint(SpringLayout.WEST, categorycombo, 0, SpringLayout.WEST, lblMaterialName);
		add(categorycombo);
		categorycombo.setPreferredSize(new Dimension(300, 23));
		
		lblSpecification = new JLabel("Specification");
		lblSpecification.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblSpecification, 20, SpringLayout.SOUTH, categorycombo);
		springLayout.putConstraint(SpringLayout.WEST, lblSpecification, 0, SpringLayout.WEST, lblMaterialName);
		add(lblSpecification);
		
		tSpecification = new JComboBox();
		tSpecification.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tSpecification, 6, SpringLayout.SOUTH, lblSpecification);
		springLayout.putConstraint(SpringLayout.WEST, tSpecification, 0, SpringLayout.WEST, lblMaterialName);
		add(tSpecification);
		tSpecification.setPreferredSize(new Dimension(300, 23));
		
		JLabel lblNewSpecification = new JLabel("New Specification");
		lblNewSpecification.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblNewSpecification, 20, SpringLayout.SOUTH, tSpecification);
		springLayout.putConstraint(SpringLayout.WEST, lblNewSpecification, 30, SpringLayout.WEST,this);
		add(lblNewSpecification);
		
		tNewSpecification = new JTextField();
		tNewSpecification.setPreferredSize(new Dimension(300, 23));
		tNewSpecification.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tNewSpecification, 6, SpringLayout.SOUTH, lblNewSpecification);
		springLayout.putConstraint(SpringLayout.WEST, tNewSpecification, 30, SpringLayout.WEST,this);
		add(tNewSpecification);
	
		lblUnit = new JLabel("Unit");
		springLayout.putConstraint(SpringLayout.WEST, lblUnit, 30, SpringLayout.WEST,this);
		springLayout.putConstraint(SpringLayout.NORTH, lblUnit, 20, SpringLayout.SOUTH,tNewSpecification);
		lblUnit.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(lblUnit);
		
		tUnit = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tUnit,6, SpringLayout.SOUTH,lblUnit);
		springLayout.putConstraint(SpringLayout.WEST, tUnit, 30, SpringLayout.WEST,this);
		tUnit.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(tUnit);
		tUnit.setPreferredSize(new Dimension(300, 23));
		
		btnStatus = new JButton("Mark Deactivate");
		btnStatus.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, btnStatus, 30, SpringLayout.WEST,this);
		springLayout.putConstraint(SpringLayout.NORTH, btnStatus, 20, SpringLayout.SOUTH,tUnit);
		add(btnStatus);
		
		JPanel panel = new JPanel();
		springLayout.putConstraint(SpringLayout.WEST, panel, 30, SpringLayout.WEST,this);
		springLayout.putConstraint(SpringLayout.NORTH, panel, 20, SpringLayout.SOUTH,btnStatus);
		add(panel);
		panel.setPreferredSize(new Dimension(300, 120));
		GridLayout g=new GridLayout(2,3,2,2);
		panel.setLayout(g);

		btnSave = new JButton("SAVE  ");
		btnSave.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSave);
		btnSave.setActionCommand("SAVE");
		buttongrp[0]=btnSave;
		
		btnClear = new JButton("CLEAR ");
		btnClear.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnClear);
		btnClear.setActionCommand("CLEAR");
		buttongrp[6]=btnClear;
		
		btnUpdate = new JButton("UPDATE");
		btnUpdate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnUpdate);
		btnUpdate.setActionCommand("UPDATE");
		buttongrp[2]=btnUpdate;
		
		btnBack = new JButton("  <<  ");
		btnBack.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnBack);
		btnBack.setActionCommand("<< ");
		buttongrp[3]=btnBack;
		
		btnSearch = new JButton("SEARCH");
		btnSearch.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSearch);
		btnSearch.setActionCommand("SEARCH");
		buttongrp[4]=btnSearch;
		
		btnForward = new JButton(">>");
		btnForward.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnForward);
		btnForward.setActionCommand(">>");
		buttongrp[5]=btnForward;
	}
	
	public JButton getBtnSave() {
		return btnSave;
	}
	
	public void setBtnSave(JButton btnSave) {
		this.btnSave = btnSave;
	}
	
	public JButton getBtnBack() {
		return btnBack;
	}

	public void setBtnBack(JButton btnBack) {
		this.btnBack = btnBack;
	}
	
	public JButton getBtnSearch() {
		return btnSearch;
	}

	public void setBtnSearch(JButton btnSearch) {
		this.btnSearch = btnSearch;
	}
	
	public JButton getBtnForward() {
		return btnForward;
	}

	public void setBtnForward(JButton btnForward) {
		this.btnForward = btnForward;
	}

	public JButton getBtnClear() {
		return btnClear;
	}
	
	public void setBtnClear(JButton btnClear) {
		this.btnClear = btnClear;
	}

	public JTextField gettMaterialName() {
		return tMaterialName;
	}

	public void settMaterialName(JTextField tMaterialName) {
		this.tMaterialName = tMaterialName;
	}
	
	public JComboBox getCategorycombo() {
		return categorycombo;
	}

	public void setCategorycombo(JComboBox categorycombo) {
		this.categorycombo = categorycombo;
	}

	public JComboBox gettSpecification() {
		return tSpecification;
	}

	public void settSpecification(JComboBox tSpecification) {
		this.tSpecification = tSpecification;
	}

	public JTextField gettMcode() {
		return tMcode;
	}

	public void settMcode(JTextField tMcode) {
		this.tMcode = tMcode;
	}

	public JTextField gettNewSpecification() {
		return tNewSpecification;
	}

	public void settNewSpecification(JTextField tNewSpecification) {
		this.tNewSpecification = tNewSpecification;
	}
	
	public JTextField gettUnit() {
		return tUnit;
	}

	public void settUnit(JTextField tUnit) {
		this.tUnit = tUnit;
	}

	public JButton getBtnStatus() {
		return btnStatus;
	}

	public void setBtnStatus(JButton btnStatus) {
		this.btnStatus = btnStatus;
	}

	public JLabel getLblActive() {
		return lblActive;
	}

	public void setLblActive(JLabel lblActive) {
		this.lblActive = lblActive;
	}

	public void actionListener(ActionListener al)
	{
		for(int i=0;i<buttongrp.length;i++)
		{
			buttongrp[i].addActionListener(al);
		}
	}
}
